package com.xtrip.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class XtripStringUtils {

	public static String formatDate1(Date d) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		return sdf.format(d);
	}

	public static String formatDate2(Date d) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
		return sdf.format(d);
	}
	public static String formatDate3(Date d) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		return sdf.format(d);
	}
	// 将xml文档转换为可传输的字符串
	public static String XMLToString(String source) {
		String result = source.replaceAll("<", "&lt;");
		result = result.replaceAll(">", "&gt;");
		return result;
	}

	// 将返回的字符串转换为可反序列化XML文本
	public static String StringToXML(String source) {
		String result = source.replaceAll("&lt;", "<");
		result = result.replaceAll("&gt;", ">");
		return result;
	}
}
